package com.chinaunicom.entity;

import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * @author: ruiyanglee
 * @date: 2020-11-06 09:20
 * @description: response result object
 */

@Data
// 开启链式编程
@Accessors(chain = true)
public class ResponseResult implements Serializable {

    private boolean flag;//是否成功
    private Integer code;//返回码
    private String message;//返回消息
    private Object data;//返回数据

    private ResponseResult() {
    }

    public static ResponseResult ok() {
        ResponseResult response = new ResponseResult();
        response.code = StatusCode.OK;
        return response;
    }

    public static ResponseResult error() {
        ResponseResult response = new ResponseResult();
        response.code = StatusCode.ERROR;
        return response;
    }

    public ResponseResult flag(boolean flag) {
        this.flag = flag;
        return this;
    }

    public ResponseResult message(String message) {
        this.message = message;
        return this;
    }

    public ResponseResult data(Object data) {
        this.data = data;
        return this;
    }

    public ResponseResult code(Integer code) {
        this.code = code;
        return this;
    }
}
